const fs = require('fs');
const path = require('path');

const srcDir = path.resolve(__dirname, 'admin/src');
const destDir = path.resolve(__dirname, 'data-admin/src');

function mergeDirs(src, dest) {
  if (!fs.existsSync(dest)) {
    fs.mkdirSync(dest, { recursive: true });
  }
  const items = fs.readdirSync(src);
  for (const item of items) {
    const srcPath = path.join(src, item);
    const destPath = path.join(dest, item);
    const stat = fs.statSync(srcPath);
    if (stat.isDirectory()) {
      mergeDirs(srcPath, destPath);
    } else if (!fs.existsSync(destPath)) {
      fs.copyFileSync(srcPath, destPath);
      console.log(`已复制: ${srcPath} -> ${destPath}`);
    } else {
      console.log(`跳过已存在文件: ${destPath}`);
    }
  }
}

mergeDirs(srcDir, destDir);
console.log('合并完成！'); 